function loadImage(url) {
  return new Promise((resolve, reject) => {
    const image = new Image()

    image.onload = function () {
      resolve(image)
    }

    image.onerror = function () {
      reject(new Error('载入失败' + url))
    }

    image.src = url
  })
}